home *** CD-ROM | disk | FTP | other *** search
- /* $VER: WBStars_CX.c 2.0b4 (29 May 1997)
- */
-
- #include <libraries/commodities.h>
- #include <libraries/dos.h>
- #include <proto/exec.h>
- #include <proto/commodities.h>
- #include <clib/alib_protos.h>
-
- #include "WBStars_include.h"
- #include "WBStars_protos.h"
-
- #define EVT_HOTKEY 1L
-
- struct MsgPort *broker_mp;
- CxObj *broker, *filter, *sender, *translate;
-
- struct NewBroker newbroker = {
- NB_VERSION,
- "WBStars",
- "WBStars 2.0b4 by Alexander Pokahr",
- "The Workbench Animator",
- NBU_UNIQUE | NBU_NOTIFY,
- 0, 0, 0, 0
- };
-
- ULONG cxsigflag;
-
- char InitCx()
- {
- CxMsg *msg;
- if( broker_mp=CreateMsgPort() )
- {
- newbroker.nb_Port = broker_mp;
- cxsigflag = 1L << broker_mp->mp_SigBit;
- newbroker.nb_Pri = CXpri;
- if( broker=CxBroker(&newbroker,NULL) )
- {
- if( filter=CxFilter(hotkey) )
- {
- AttachCxObj(broker, filter);
- if( sender=CxSender(broker_mp,EVT_HOTKEY) )
- {
- AttachCxObj(filter, sender);
- if( translate=(CxTranslate(NULL)) )
- {
- AttachCxObj(filter, translate);
- if( !CxObjError(filter) )
- {
- if( Activate() ) ActivateCxObj(broker, 1L);
- else ActivateCxObj(broker, 0L);
- return TRUE;
- }
- }
- }
- }
- DeleteCxObjAll(broker);
- while( msg=(CxMsg *)GetMsg(broker_mp) )
- ReplyMsg((struct Message *)msg);
- }
- DeletePort(broker_mp);
- }
- return FALSE;
- }
-
- void RemovCx()
- {
- CxMsg *msg;
-
- DeleteCxObjAll(broker);
-
- while( msg=(CxMsg *)GetMsg(broker_mp) )
- ReplyMsg((struct Message *)msg);
-
- DeletePort(broker_mp);
- }
-
- char HandleCx()
- {
- extern struct MsgPort *broker_mp;
- extern CxObj *broker;
- extern ULONG cxsigflag;
- CxMsg *msg;
- ULONG msgid, msgtype;
-
- while(msg = (CxMsg *)GetMsg(broker_mp))
- {
- msgid = CxMsgID(msg);
- msgtype = CxMsgType(msg);
- ReplyMsg((struct Message *)msg);
-
- switch(msgtype)
- {
- case CXM_IEVENT:
- switch(msgid)
- {
- case EVT_HOTKEY:
- if( activated )
- {
- Inactivate();
- }
- else
- {
- Activate();
- }
- break;
- }
- break;
- case CXM_COMMAND:
- switch(msgid)
- {
- case CXCMD_DISABLE:
- ActivateCxObj(broker, 0L);
- Inactivate();
- break;
- case CXCMD_ENABLE:
- if( Activate() ) ActivateCxObj(broker, 1L);
- break;
- case CXCMD_KILL:
- return FALSE;
- break;
- case CXCMD_UNIQUE:
- return FALSE;
- break;
- case CXCMD_APPEAR:
- break;
- case CXCMD_DISAPPEAR:
- break;
- }
- break;
- }
- }
-
- if( SetSignal(0L,SIGBREAKF_CTRL_C)&SIGBREAKF_CTRL_C )return FALSE;
-
- return TRUE;
- }